home *** CD-ROM | disk | FTP | other *** search
- Path: netcad.enet.dec.com!branam
- From: branam@netcad.enet.dec.com ()
- Newsgroups: comp.lang.c++,comp.lang.c,comp.graphics.algorithms,comp.os.ms-windows.programmer.graphics
- Subject: Re: Urgent question
- Date: 5 Feb 1996 18:01:00 GMT
- Organization: Digital Equipment Corporation
- Distribution: world
- Message-ID: <4f5gks$76l@nntpd.lkg.dec.com>
- References: <4dg18o$lm4@news.ust.hk>
- Reply-To: branam@netcad.enet.dec.com ()
- NNTP-Posting-Host: kali.enet.dec.com
- X-Newsreader: mxrn 6.18-30
-
-
- To knit together several bitmaps into a single mosaic using MS-Windows GDI
- routines, try the following general algorithm (assume 256-color bitmaps):
-
- Allocate memory for target bitmap data buffer: 1 byte per pixel.
- For each source bitmap:
- Allocate memory for source bitmap data buffer: 1 byte per pixel.
- Construct BITMAPINFO block describing Device Independent Bitmap.
- GetDIBits() using source bitmap handle, specifying
- source memory bitmap data buffer.
- Compute offset into target data buffer of the starting XY coordinate
- for this bitmap.
- Compute increment to next row of target data buffer.
- Compute increment to next row of source data buffer (offset will
- start at 0).
- For each row of source bitmap data:
- Copy bits from source bitmap data buffer to current offset of
- target buffer.
- Add target increment to target offset.
- Add source increment to source offset.
- Endfor.
- Free source bitmap data buffer.
- Endfor.
- Construct BITMAPINFO block for target bitmap.
- CreateDIBitmap() using target data buffer to create a device dependent
- bitmap, returning an HBITMAP.
- Free target bitmap data buffer.
-
- Compute the offsets, row widths, and increments for bitmap data buffer rows
- using the info in the BITMAPINFO blocks.
-
- This requires memory for the entire target bitmap data buffer and one source
- bitmap data buffer at a time. Since these could be big, use fixed global memory
- blocks (there is no advantage to making them moveable because you are not
- keeping them around).
-
- You also need to resolve the color palette if the bitmaps you are assembling
- have different palettes.
-